package com.designpattern.demo.design2;

/**
 * Created by lingchen on 2019/11/26. 20:56
 * mail:lingchen52@foxmail.com
 */
public class CashContext {

    private CashSuper cs = null;

    public CashContext(String type) {
        switch (type) {
            case "正常收费":
                cs = new CashNormal();
                break;
            case "打8折":
                cs = new CashRabate("8");
                break;
            case "满300返100":
                cs = new CashReturn(300, 100);
                break;
            default:
                break;
        }
    }

    public double getResult(double money) {
        return cs.acceptCash(money);
    }
}
